<%--
  Created by IntelliJ IDEA.
  User: 67693
  Date: 2021/7/21
  Time: 14:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <meta charset="utf-8">
    <title>testOrderInfo</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/library/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/library/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">

    <div class="layui-form-item">
        <label class="layui-form-label">商品号</label>
        <div class="layui-input-block">
            <input class="layui-input" type="text" readonly name="id" id="id" value="${id}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">商品名</label>
        <div class="layui-input-block">
            <input class="layui-input" lay-verify="required" type="text" name="name" id="name" value="${name}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">商品描述</label>
        <div class="layui-input-block">
            <input class="layui-input" type="text" name="des" id="des" value="${des}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">价格（元）</label>
        <div class="layui-input-block">
            <input class="layui-input" type="number" name="price" id="price" value="${price}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">库存</label>
        <div class="layui-input-block">
            <input class="layui-input" type="number" lay-verify="required" name="count" id="count" value="${count}">
        </div>
    </div>
    
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="confirmUpdate">确认修改</button>
        </div>
    </div>
</div>
<script src="/library/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(confirmUpdate)', function (data) {
            var datas=data.field;//form单中的数据信息
                //向后台发送数据提交添加
                $.ajax({
                    url:"/updateProductSubmit",
                    type:"POST",
                    data: {
                        id:datas.id,
                        name:datas.name,
                        des:datas.des,
                        price:datas.price,
                        count:datas.count
                    },
                    success:function(result){
                        if(result.code==0){//如果成功
                            layer.msg("修改成功",{
                                icon:6,
                                time:500
                            },function(){
                                parent.window.location.reload();
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            })
                        }else{
                            layer.msg("修改成功",{
                                icon:6,
                                time:500
                            });
                        }
                    }
                })
            return false;
        });

    });
</script>
</body>
</html>
